home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Technology Seed / Jan. '98 ATS.toast / QuickTime™ 3.0b11 / QTPublicInterfaces / CIncludes / ColorPicker.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-12  |  8.9 KB  |  303 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        ColorPicker.h
  3.  
  4.      Contains:    Color Picker package Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    QuickTime 3.0 Beta
  8.  
  9.      Copyright:    © 1987-1997 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __COLORPICKER__
  19. #define __COLORPICKER__
  20.  
  21. #ifndef __MIXEDMODE__
  22. #include <MixedMode.h>
  23. #endif
  24. #ifndef __QUICKDRAW__
  25. #include <Quickdraw.h>
  26. #endif
  27. #ifndef __CMAPPLICATION__
  28. #include <CMApplication.h>
  29. #endif
  30.  
  31.  
  32.  
  33. #if PRAGMA_ONCE
  34. #pragma once
  35. #endif
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40.  
  41. #if PRAGMA_IMPORT
  42. #pragma import on
  43. #endif
  44.  
  45. #if PRAGMA_STRUCT_ALIGN
  46.     #pragma options align=mac68k
  47. #elif PRAGMA_STRUCT_PACKPUSH
  48.     #pragma pack(push, 2)
  49. #elif PRAGMA_STRUCT_PACK
  50.     #pragma pack(2)
  51. #endif
  52.  
  53.  
  54. enum {
  55.                                                                 /*Maximum small fract value, as long*/
  56.     kMaximumSmallFract            = 0x0000FFFF
  57. };
  58.  
  59.  
  60. enum {
  61.     kDefaultColorPickerWidth    = 383,
  62.     kDefaultColorPickerHeight    = 238
  63. };
  64.  
  65.  
  66. enum {
  67.     kAtSpecifiedOrigin            = 0,
  68.     kDeepestColorScreen            = 1,
  69.     kCenterOnMainScreen            = 2
  70. };
  71.  
  72. typedef short                             DialogPlacementSpec;
  73. /* These are for the flags field in the structs below (for example ColorPickerInfo). */
  74.  
  75. enum {
  76.     kColorPickerDialogIsMoveable = 1,
  77.     kColorPickerDialogIsModal    = 2,
  78.     kColorPickerCanModifyPalette = 4,
  79.     kColorPickerCanAnimatePalette = 8,
  80.     kColorPickerAppIsColorSyncAware = 16,
  81.     kColorPickerInSystemDialog    = 32,
  82.     kColorPickerInApplicationDialog = 64,
  83.     kColorPickerInPickerDialog    = 128,
  84.     kColorPickerDetachedFromChoices = 256,
  85.     kColorPickerCallColorProcLive = 512
  86. };
  87.  
  88.  
  89. #if OLDROUTINENAMES
  90.  
  91. enum {
  92.                                                                 /*Maximum small fract value, as long*/
  93.     MaxSmallFract                = 0x0000FFFF
  94. };
  95.  
  96.  
  97. enum {
  98.     kDefaultWidth                = 383,
  99.     kDefaultHeight                = 238
  100. };
  101.  
  102. /* These are for the flags field in the structs below (for example ColorPickerInfo). */
  103.  
  104. enum {
  105.     DialogIsMoveable            = 1,
  106.     DialogIsModal                = 2,
  107.     CanModifyPalette            = 4,
  108.     CanAnimatePalette            = 8,
  109.     AppIsColorSyncAware            = 16,
  110.     InSystemDialog                = 32,
  111.     InApplicationDialog            = 64,
  112.     InPickerDialog                = 128,
  113.     DetachedFromChoices            = 256,
  114.     CallColorProcLive            = 512
  115. };
  116.  
  117. #endif  /* OLDROUTINENAMES */
  118.  
  119. /* A SmallFract value is just the fractional part of a Fixed number,
  120. which is the low order word.  SmallFracts are used to save room,
  121. and to be compatible with Quickdraw's RGBColor.  They can be
  122. assigned directly to and from INTEGERs. */
  123. /* Unsigned fraction between 0 and 1 */
  124. typedef unsigned short                     SmallFract;
  125. /* For developmental simplicity in switching between the HLS and HSV
  126. models, HLS is reordered into HSL. Thus both models start with
  127. hue and saturation values; value/lightness/brightness is last. */
  128.  
  129.  
  130. struct HSVColor {
  131.     SmallFract                         hue;                        /*Fraction of circle, red at 0*/
  132.     SmallFract                         saturation;                    /*0-1, 0 for gray, 1 for pure color*/
  133.     SmallFract                         value;                        /*0-1, 0 for black, 1 for max intensity*/
  134. };
  135. typedef struct HSVColor                    HSVColor;
  136.  
  137. struct HSLColor {
  138.     SmallFract                         hue;                        /*Fraction of circle, red at 0*/
  139.     SmallFract                         saturation;                    /*0-1, 0 for gray, 1 for pure color*/
  140.     SmallFract                         lightness;                    /*0-1, 0 for black, 1 for white*/
  141. };
  142. typedef struct HSLColor                    HSLColor;
  143.  
  144. struct CMYColor {
  145.     SmallFract                         cyan;
  146.     SmallFract                         magenta;
  147.     SmallFract                         yellow;
  148. };
  149. typedef struct CMYColor                    CMYColor;
  150.  
  151. struct PMColor {
  152.     CMProfileHandle                 profile;
  153.     CMColor                         color;
  154. };
  155. typedef struct PMColor                    PMColor;
  156. typedef PMColor *                        PMColorPtr;
  157.  
  158. struct NPMColor {
  159.     CMProfileRef                     profile;
  160.     CMColor                         color;
  161. };
  162. typedef struct NPMColor                    NPMColor;
  163. typedef NPMColor *                        NPMColorPtr;
  164. typedef struct OpaquePicker*             Picker;
  165. typedef Picker picker;
  166.  
  167. struct PickerMenuItemInfo {
  168.     short                             editMenuID;
  169.     short                             cutItem;
  170.     short                             copyItem;
  171.     short                             pasteItem;
  172.     short                             clearItem;
  173.     short                             undoItem;
  174. };
  175. typedef struct PickerMenuItemInfo        PickerMenuItemInfo;
  176. /* Structs related to deprecated API's have been pulled from this file. */
  177. /* Those structs necessary for developers writing their own color pickers... */
  178. /* have been moved to ColorPickerComponents.h. */
  179.  
  180. typedef CALLBACK_API( void , ColorChangedProcPtr )(long userData, PMColor *newColor);
  181. typedef CALLBACK_API( void , NColorChangedProcPtr )(long userData, NPMColor *newColor);
  182. typedef CALLBACK_API( Boolean , UserEventProcPtr )(EventRecord *event);
  183. typedef STACK_UPP_TYPE(ColorChangedProcPtr)                     ColorChangedUPP;
  184. typedef STACK_UPP_TYPE(NColorChangedProcPtr)                     NColorChangedUPP;
  185. typedef STACK_UPP_TYPE(UserEventProcPtr)                         UserEventUPP;
  186.  
  187. struct ColorPickerInfo {
  188.     PMColor                         theColor;
  189.     CMProfileHandle                 dstProfile;
  190.     UInt32                             flags;
  191.     DialogPlacementSpec             placeWhere;
  192.     Point                             dialogOrigin;
  193.     OSType                             pickerType;
  194.     UserEventUPP                     eventProc;
  195.     ColorChangedUPP                 colorProc;
  196.     UInt32                             colorProcData;
  197.     Str255                             prompt;
  198.     PickerMenuItemInfo                 mInfo;
  199.     Boolean                         newColorChosen;
  200.     SInt8                             filler;
  201. };
  202. typedef struct ColorPickerInfo            ColorPickerInfo;
  203.  
  204. struct NColorPickerInfo {
  205.     NPMColor                         theColor;
  206.     CMProfileRef                     dstProfile;
  207.     UInt32                             flags;
  208.     DialogPlacementSpec             placeWhere;
  209.     Point                             dialogOrigin;
  210.     OSType                             pickerType;
  211.     UserEventUPP                     eventProc;
  212.     NColorChangedUPP                 colorProc;
  213.     UInt32                             colorProcData;
  214.     Str255                             prompt;
  215.     PickerMenuItemInfo                 mInfo;
  216.     Boolean                         newColorChosen;
  217.     UInt8                             reserved;                    /*Must be 0*/
  218. };
  219. typedef struct NColorPickerInfo            NColorPickerInfo;
  220. /*    Below are the color conversion routines.*/
  221. EXTERN_API( SmallFract )
  222. Fix2SmallFract                    (Fixed                     f)                                    THREEWORDINLINE(0x3F3C, 0x0001, 0xA82E);
  223.  
  224. EXTERN_API( Fixed )
  225. SmallFract2Fix                    (SmallFract             s)                                    THREEWORDINLINE(0x3F3C, 0x0002, 0xA82E);
  226.  
  227. EXTERN_API( void )
  228. CMY2RGB                            (const CMYColor *        cColor,
  229.                                  RGBColor *                rColor)                                THREEWORDINLINE(0x3F3C, 0x0003, 0xA82E);
  230.  
  231. EXTERN_API( void )
  232. RGB2CMY                            (const RGBColor *        rColor,
  233.                                  CMYColor *                cColor)                                THREEWORDINLINE(0x3F3C, 0x0004, 0xA82E);
  234.  
  235. EXTERN_API( void )
  236. HSL2RGB                            (const HSLColor *        hColor,
  237.                                  RGBColor *                rColor)                                THREEWORDINLINE(0x3F3C, 0x0005, 0xA82E);
  238.  
  239. EXTERN_API( void )
  240. RGB2HSL                            (const RGBColor *        rColor,
  241.                                  HSLColor *                hColor)                                THREEWORDINLINE(0x3F3C, 0x0006, 0xA82E);
  242.  
  243. EXTERN_API( void )
  244. HSV2RGB                            (const HSVColor *        hColor,
  245.                                  RGBColor *                rColor)                                THREEWORDINLINE(0x3F3C, 0x0007, 0xA82E);
  246.  
  247. EXTERN_API( void )
  248. RGB2HSV                            (const RGBColor *        rColor,
  249.                                  HSVColor *                hColor)                                THREEWORDINLINE(0x3F3C, 0x0008, 0xA82E);
  250.  
  251.  
  252. /*    GetColor() works with or without the Color Picker extension.*/
  253. EXTERN_API( Boolean )
  254. GetColor                        (Point                     where,
  255.                                  ConstStr255Param         prompt,
  256.                                  const RGBColor *        inColor,
  257.                                  RGBColor *                outColor)                            THREEWORDINLINE(0x3F3C, 0x0009, 0xA82E);
  258.  
  259. /*    PickColor() requires the Color Picker extension (version 2.0 or greater).*/
  260. EXTERN_API( OSErr )
  261. PickColor                        (ColorPickerInfo *        theColorInfo)                        THREEWORDINLINE(0x3F3C, 0x0213, 0xA82E);
  262.  
  263. /*    NPickColor() requires the Color Picker extension (version 2.1 or greater).*/
  264. EXTERN_API( OSErr )
  265. NPickColor                        (NColorPickerInfo *        theColorInfo)                        THREEWORDINLINE(0x3F3C, 0x0227, 0xA82E);
  266.  
  267.  
  268. /* A suite of mid-level API calls have been deprecated.  Likely you never...  */
  269. /* used them anyway.  They were removed from this file and should not be... */
  270. /* used in the future as they are not gauranteed to be supported. */
  271.  
  272. enum { uppColorChangedProcInfo = 0x000003C0 };                     /* pascal no_return_value Func(4_bytes, 4_bytes) */
  273. enum { uppNColorChangedProcInfo = 0x000003C0 };                 /* pascal no_return_value Func(4_bytes, 4_bytes) */
  274. enum { uppUserEventProcInfo = 0x000000D0 };                     /* pascal 1_byte Func(4_bytes) */
  275. #define NewColorChangedProc(userRoutine)                         (ColorChangedUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppColorChangedProcInfo, GetCurrentArchitecture())
  276. #define NewNColorChangedProc(userRoutine)                         (NColorChangedUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppNColorChangedProcInfo, GetCurrentArchitecture())
  277. #define NewUserEventProc(userRoutine)                             (UserEventUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppUserEventProcInfo, GetCurrentArchitecture())
  278. #define CallColorChangedProc(userRoutine, userData, newColor)     CALL_TWO_PARAMETER_UPP((userRoutine), uppColorChangedProcInfo, (userData), (newColor))
  279. #define CallNColorChangedProc(userRoutine, userData, newColor)     CALL_TWO_PARAMETER_UPP((userRoutine), uppNColorChangedProcInfo, (userData), (newColor))
  280. #define CallUserEventProc(userRoutine, event)                     CALL_ONE_PARAMETER_UPP((userRoutine), uppUserEventProcInfo, (event))
  281.  
  282.  
  283. #if PRAGMA_STRUCT_ALIGN
  284.     #pragma options align=reset
  285. #elif PRAGMA_STRUCT_PACKPUSH
  286.     #pragma pack(pop)
  287. #elif PRAGMA_STRUCT_PACK
  288.     #pragma pack()
  289. #endif
  290.  
  291. #ifdef PRAGMA_IMPORT_OFF
  292. #pragma import off
  293. #elif PRAGMA_IMPORT
  294. #pragma import reset
  295. #endif
  296.  
  297. #ifdef __cplusplus
  298. }
  299. #endif
  300.  
  301. #endif /* __COLORPICKER__ */
  302.  
  303.